---------------------------------------------------------------------------------------------------------------------------------------

. do "K:\Jan - PACs\2004 Final Submission - April\Data Archive\splitpop.do"

. * To call up the model, issue this command:
. *       ml model lf splitpps (duration: duration = x1 x2 ...) (logit: censor = x1 x2 ...) /shape
. *
. *       To maximize the function, issue the "ml max" command. For more difficult models, use "ml max, difficult". 
. *       For better starting values, issue "ml search" after calling up the model and before maximizing it. 
. 
. program define splitpps
  1.         args lnf theta1 theta2 theta3 
  2.         tempvar p s d l 
  3.         quietly gen double `l'=exp(-`theta1')
  4.         quietly gen double `d'=exp(`theta2')/(1+exp(`theta2'))
  5.         quietly gen double `s'=1- `d' +`d'*(1/(1+(`l'*$ML_y1)^(1/`theta3')))
  6.         quietly gen double `p'=ln(`d')-ln(`theta3')+((1/`theta3')-1)*ln($ML_y1)+(1/`theta3')*ln(`l')-2*ln(1+(`l'*$ML_y1)^(1/`the
> ta3'))
  7.         quietly replace `lnf'=$ML_y2*(`p')+(1-$ML_y2)*ln(`s')
  8. end

. 
end of do-file

** LARGE LABOR PACS MODEL **

. ml model lf splitpps (duration: T = educatn prestige seniorty dleader rleader republic cope votepct quality pquality bcash lagprecp
>  recpsqrd totpct stshare homecand dcpac) (logit: gave = educatn prestige seniorty dleader rleader republic cope votepct quality pqu
> ality bcash lagprecp recpsqrd totpct stshare homecand dcpac) /shape if large==1

. ml search
initial:       log likelihood =     -<inf>  (could not be evaluated)
feasible:      log likelihood = -73241.643
improve:       log likelihood = -41736.789
rescale:       log likelihood = -40900.402
rescale eq:    log likelihood = -40014.636

. ml max

initial:       log likelihood = -40014.636
rescale:       log likelihood = -39777.084
rescale eq:    log likelihood = -36559.317
Iteration 0:   log likelihood = -36559.317  (not concave)
Iteration 1:   log likelihood = -34434.346  
Iteration 2:   log likelihood = -34048.299  
Iteration 3:   log likelihood = -33866.337  
Iteration 4:   log likelihood = -33857.754  
Iteration 5:   log likelihood = -33857.726  
Iteration 6:   log likelihood = -33857.726  

                                                  Number of obs   =      10168
                                                  Wald chi2(17)   =     534.57
Log likelihood = -33857.726                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
duration     |
     educatn |   .0657934   .0465943     1.41   0.158    -.0255297    .1571166
    prestige |   .0375843   .0296507     1.27   0.205    -.0205299    .0956986
    seniorty |   .2655538   .1936917     1.37   0.170     -.114075    .6451826
     dleader |  -.2008474   .0426538    -4.71   0.000    -.2844473   -.1172475
     rleader |  -.2369235   .1366632    -1.73   0.083    -.5047784    .0309314
    republic |  -.0596892    .060448    -0.99   0.323    -.1781651    .0587866
        cope |  -.2930568    .108651    -2.70   0.007    -.5060089   -.0801047
     votepct |   .3198831   .1227685     2.61   0.009     .0792613     .560505
     quality |   .0164541    .043222     0.38   0.703    -.0682594    .1011677
    pquality |   .0376763   .0765443     0.49   0.623    -.1123477    .1877002
       bcash |   .3514341   .0716984     4.90   0.000     .2109078    .4919604
    lagprecp |  -.2789671   .0200107   -13.94   0.000    -.3181873   -.2397469
    recpsqrd |   .0259331   .0023862    10.87   0.000     .0212563      .03061
      totpct |  -.5041463   .2263587    -2.23   0.026    -.9478013   -.0604914
     stshare |   .4819198   .1913305     2.52   0.012      .106919    .8569207
    homecand |  -.2420607   .1037069    -2.33   0.020    -.4453224    -.038799
       dcpac |   .4026476   .0298946    13.47   0.000     .3440552    .4612399
       _cons |   5.717728   .1143268    50.01   0.000     5.493652    5.941804
-------------+----------------------------------------------------------------
logit        |
     educatn |   .1092988   .1184172     0.92   0.356    -.1227947    .3413923
    prestige |   .2806099   .0635753     4.41   0.000     .1560045    .4052152
    seniorty |  -.7225828   .3885569    -1.86   0.063     -1.48414    .0389747
     dleader |   .4483005    .117503     3.82   0.000     .2179988    .6786022
     rleader |   .2813031   .1753403     1.60   0.109    -.0623576    .6249638
    republic |  -1.798423   .1000995   -17.97   0.000    -1.994614   -1.602231
        cope |   3.250226   .2013426    16.14   0.000     2.855602     3.64485
     votepct |  -2.374621     .26542    -8.95   0.000    -2.894835   -1.854408
     quality |   .2355944   .0915296     2.57   0.010     .0561997     .414989
    pquality |  -.4067092   .1496391    -2.72   0.007    -.6999964    -.113422
       bcash |  -.4111928   .1515213    -2.71   0.007    -.7081691   -.1142164
    lagprecp |   .4141835   .0447867     9.25   0.000     .3264031    .5019638
    recpsqrd |  -.0333042   .0054234    -6.14   0.000    -.0439338   -.0226746
      totpct |   3.878043   .4972923     7.80   0.000     2.903368    4.852718
     stshare |    .818243   .4648729     1.76   0.078    -.0928911    1.729377
    homecand |    .298608   .2603486     1.15   0.251     -.211666    .8088819
       dcpac |   .0935253   .0631602     1.48   0.139    -.0302663     .217317
       _cons |  -1.331899   .2248491    -5.92   0.000    -1.772595   -.8912029
-------------+----------------------------------------------------------------
shape        |
       _cons |   .4803252   .0074244    64.70   0.000     .4657737    .4948767
------------------------------------------------------------------------------

** NOTE: For ease of interpretation, we switched the signs of the duration coefficients in tables 1 and 2 of the paper. See the paper for interpretation. **


. predict xb_large, eq(logit)

. gen prob_large=exp(xb_large)/(1+exp(xb_large))

. su prob_large if large==1

** MEAN IS ESTIMATED SPLIT **

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
  prob_large |     10168    .4719391     .317901   .0084166   .9725916

. su gave if large==1

** MEAN IS OBSERVED SPLIT **

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        gave |     10168    .4353855    .4958318          0          1


** SMALL LABOR PACS MODEL **

. ml model lf splitpps (duration: T = educatn prestige seniorty dleader rleader republic cope votepct quality pquality bcash lagprecp
>  recpsqrd totpct stshare homecand dcpac) (logit: gave = educatn prestige seniorty dleader rleader republic cope votepct quality pqu
> ality bcash lagprecp recpsqrd totpct stshare homecand dcpac) /shape if large==0

. ml max, difficult

initial:       log likelihood =     -<inf>  (could not be evaluated)
feasible:      log likelihood = -54821.531
rescale:       log likelihood = -54821.531
rescale eq:    log likelihood =  -14574.49
Iteration 0:   log likelihood =  -14574.49  (not concave)
Iteration 1:   log likelihood = -13945.135  (not concave)
Iteration 2:   log likelihood = -13109.871  (not concave)
Iteration 3:   log likelihood = -13077.103  (not concave)
Iteration 4:   log likelihood = -12957.184  
Iteration 5:   log likelihood = -12917.829  
Iteration 6:   log likelihood = -12902.827  
Iteration 7:   log likelihood = -12902.374  
Iteration 8:   log likelihood = -12902.372  
Iteration 9:   log likelihood = -12902.372  

                                                  Number of obs   =      36208
                                                  Wald chi2(17)   =      77.19
Log likelihood = -12902.372                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
duration     |
     educatn |   .0278776   .0756763     0.37   0.713    -.1204453    .1762004
    prestige |   .0217966   .0535608     0.41   0.684    -.0831807    .1267739
    seniorty |   .3160046   .3787237     0.83   0.404    -.4262802    1.058289
     dleader |  -.1005385   .0722409    -1.39   0.164     -.242128     .041051
     rleader |   .0681627    .225974     0.30   0.763    -.3747381    .5110635
    republic |  -.1967517   .1197935    -1.64   0.101    -.4315426    .0380392
        cope |  -.0271159   .1984214    -0.14   0.891    -.4160147    .3617829
     votepct |   .3732552   .2310233     1.62   0.106    -.0795422    .8260526
     quality |   .2014719    .077967     2.58   0.010     .0486594    .3542843
    pquality |  -.0031042   .1495727    -0.02   0.983    -.2962612    .2900528
       bcash |  -.0339727   .1256687    -0.27   0.787    -.2802789    .2123335
    lagprecp |  -1.781076   .2490354    -7.15   0.000    -2.269176   -1.292976
    recpsqrd |   .9381453   .1626356     5.77   0.000     .6193855    1.256905
      totpct |  -.5652158   .4129509    -1.37   0.171    -1.374585    .2441532
     stshare |  -.2465977   .1329284    -1.86   0.064    -.5071326    .0139372
    homecand |  -.0682093   .0702369    -0.97   0.331     -.205871    .0694524
       dcpac |   .1010069   .0571306     1.77   0.077    -.0109671    .2129809
       _cons |   6.194481   .2235459    27.71   0.000     5.756339    6.632623
-------------+----------------------------------------------------------------
logit        |
     educatn |   .2294995   .1047446     2.19   0.028     .0242038    .4347951
    prestige |   .0330112   .0709317     0.47   0.642    -.1060124    .1720347
    seniorty |   .7881827   .4702735     1.68   0.094    -.1335364    1.709902
     dleader |   .4604189   .0978913     4.70   0.000     .2685554    .6522824
     rleader |    .173778   .2951992     0.59   0.556    -.4048019    .7523578
    republic |  -1.368205   .1528834    -8.95   0.000    -1.667851   -1.068559
        cope |    1.42004   .2712253     5.24   0.000     .8884485    1.951632
     votepct |  -1.706122     .30647    -5.57   0.000    -2.306792   -1.105451
     quality |    .508667   .1041835     4.88   0.000      .304471    .7128629
    pquality |  -.2907826   .1805589    -1.61   0.107    -.6446716    .0631064
       bcash |  -.4295879   .1560042    -2.75   0.006    -.7353506   -.1238252
    lagprecp |   4.414701   .3092637    14.27   0.000     3.808555    5.020847
    recpsqrd |  -1.888204   .2167096    -8.71   0.000    -2.312947   -1.463461
      totpct |   3.050125   .5422184     5.63   0.000     1.987396    4.112853
     stshare |    .746903   .2029565     3.68   0.000     .3491156    1.144691
    homecand |   2.255779   .0994127    22.69   0.000     2.060934    2.450624
       dcpac |   1.303365   .0785258    16.60   0.000     1.149457    1.457272
       _cons |   -4.43289   .2822181   -15.71   0.000    -4.986027   -3.879752
-------------+----------------------------------------------------------------
shape        |
       _cons |   .4339682   .0146989    29.52   0.000     .4051589    .4627774
------------------------------------------------------------------------------

** NOTE: For ease of interpretation, we switched the signs of the duration coefficients in tables 1 and 2 of the paper. See the paper for interpretation. **


. predict xb_small, eq(logit)

. gen prob_small=exp(xb_small)/(1+exp(xb_small))

. su prob_small if large==0

** MEAN IS ESTIMATED SPLIT **

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
  prob_small |     36208    .0417482    .0694282   .0007938   .8104074

. su gave if large==0

** MEAN IS OBSERVED SPLIT **

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        gave |     36208     .034937    .1836229          0          1

. log close

-------------------------------------------------------------------------------------------------------------------------------------
